<?php
class NConfirmAction extends CommonAction {

    public function index()
    {
        $NativeCount = M('Native_count');

        if(isset($_POST['send']))
        {
            $type = $this->_post('type');
            $date =  date('Y-m-d');

            $map['date'] = $date;
            $map['type'] = $type;

            if($NativeCount->where($map)->find())
            {
                $NativeCount->where($map)->setInc('number', 1);
                redirectByModal('确认成功!', self::$SUCCESS, __URL__.'/index');
                return ;
            }

            $data['type'] = $this->_post('type');
            $data['number'] = 1;
            $data['date'] = $date;

            if($NativeCount->add($data))
                redirectByModal('确认成功!', self::$SUCCESS, __URL__.'/index');
        }

        $this->display();
    }
}